package com.ljx.funchat.user.service.impl;

import cn.hutool.json.JSONUtil;
import com.ljx.funchat.transaction.service.RabbitMqProducer;
import com.ljx.funchat.common.domain.dto.PushMessageDTO;
import com.ljx.funchat.websocket.domain.vo.resp.WSBaseResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 封装推送前端消息
 */
@Service
public class PushService {

    @Autowired
    private RabbitMqProducer rabbitMqProducer;

    public void sendPushMsg(String key, WSBaseResp<?> msg, List<Long> uidList) {
        rabbitMqProducer.sendMsg(key, JSONUtil.toJsonStr(new PushMessageDTO(uidList, msg)));
    }

    public void sendPushMsg(String key, WSBaseResp<?> msg){
        rabbitMqProducer.sendMsg(key, JSONUtil.toJsonStr(new PushMessageDTO(msg)));
    }

}
